@extends('layout.app') @section('content')

    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>

    <script>
        $(document).ready(function() {

            var data = {
                url: "/setting/user",
                colNames: ['Id', '账号', '名称', '角色', '备注'],
                colModel: [{
                    name: 'user_id',
                    index: 'user_id',
                    key: true,
                }, {
                    name: 'email',
                    editable: true,
                }, {
                    name: 'name',
                    editable: true,
                }, {
                    name: 'role_id',
                    stype: 'select',
                    searchoptions: {
                        value: "{{$rs}}"
                    },
                    editable: true,
                    edittype: 'select',
                    editoptions: {
                        value: "{{$rs}}"
                    },
                    formatter: function(cellvalue, options, object) {
                        return object.rs;
                    }
                },  {
                    name: 'desc',
                    edittype: 'textarea',
                    editable: true,
                    editoptions: {
                        rows: "2",
                        cols: "40"
                    },
                    sortable: false,
                }],
                caption: '<i class="fa fa-user"></i> 用户列表',
                editurl: "/setting/user/edit",
                sortname: 'user_id',
                sortorder: "desc",

            };

            jqGrid(data, true, true, true);
        });

        function model(id) {
            $("input[name=id]").val(id);

            $.ajax({
                type: "GET",
                url: "/platform/" + id,
                dataType: "json",
                success: function(data) {
                    $("input[name=ids\\[\\]]").each(function() {
                        $(this).prop("checked", false);
                        for (index in data) {
                            if ($(this).val() == data[index]) {
                                $(this).prop("checked", true);
                            }
                        }
                    })

                    $('#platformModal').modal();
                }
            });
        }
    </script>

    <div class="modal fade" id="platformModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title"><i class="fa fa-user"></i> 用户渠道</h4>
                </div>
                <div class="modal-body">
                    <form id="aclForm" method="post" action="/platform/user">
                        {!! csrf_field() !!}
                        <input type="hidden" name="id" value="" />
                        <table class="table table-bordered table-condensed table-hover">
                            <thead>
                            </thead>
                            <tbody>
                            <?php $col = 4; ?>
                            <?php $i = 0;?>
                            <tr>
                                @foreach(\App\Models\Platform::all() as $platform)
                                    <?php $i++ ?>
                                    <td width="25%">
                                        <input type="checkbox" name="ids[]" value="{{$platform->id}}" />
                                        <span class="">{{$platform->name}}({{$platform->id}})</span>
                                    </td>
                                    @if($i % $col == 0)
                            </tr>
                            <tr>
                                @endif @endforeach
                                <?php $m = $i % $col; if($m > 0):?> @for($j = $col ; $j > $m ; $j--)
                                    <td></td>
                                @endfor
                                <?php endif?>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success" onclick="$('#aclForm').submit()"><i class="fa fa-save"></i> 确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
@endsection